home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / prog_gen / xv_pc16a.zip / XVIEW.H < prev    next >
C/C++ Source or Header  |  1994-04-20  |  11KB  |  245 lines

  1. #ifndef XVIEWH
  2. #define XVIEWH
  3.  
  4. #include <graphics.h>
  5.  
  6. /*
  7.  Header for the XView-PC graphical user interface. Turbo C version.
  8.  By Antonio Carlos Moreirao de Queiroz - acmq@coe.ufrj.br
  9.  Version 1.0 - 05/07/92
  10.  Version 1.6 - 20/11/93 Large images
  11.  Version 1.6a - 15/04/94 As version 1.6a in Pascal
  12.  
  13. The C version of the package is formed by the files:
  14. XVIEW.H, XVIEW.OBJ: Interface routines.
  15. MICKEY.H, MICKEY.OBJ: Mouse support.
  16. X_MAKE.EXE: Interface editor for Pascal and C.
  17.  
  18. To compile a program:
  19. - Use Turbo C++ 1.0 or later version.
  20. - Open a project with MICKEY.OBJ, XVIEW.OBJ, and the C source files.
  21. - Turn on the linking with the graphics and floating point libraries.
  22. - Set the memory model to "huge".
  23. - Set the CPP extensions only option.
  24. - Or for use with a C++ program, set the C++ always option, and use
  25.   the .OBJ files in the file XVCPP.ZIP.
  26. - The object files were generated with Borland C++ 3.1.
  27.   Some incompatibilities with other versions, specially in the C++ version,
  28.   may exist.
  29. - The BGI drivers needed may be also of a different version than the ones
  30.   provided for the Turbo Pascal 7.0 version.
  31.  
  32. This documentation covers only the differences between the Pascal and C
  33. versions. See the files XVIEW_PC.TXT and XVIEW.INT for more details.
  34.  
  35. General observations:
  36.  
  37. The fields of the "xv_widget" union are acessed in a more complex form.
  38. Examples:
  39. "obj^.x" translates to "obj->x"
  40. "obj^.sel_menu" translates to "obj->v.smenu.sel_menu"
  41. "obj^.gr_out.x1" translates to "obj->v.sframe.gra-out.left"
  42. An idea is to use defines for common fields, or to implement functions to
  43. access the object fields, like the Sun XView "xv_create, "xv_set" and
  44. "xv_get" functions.
  45.  
  46. Memory usage:
  47.  
  48. Each object uses in the heap:
  49. - "sizeof(xv_widget)" bytes (262).
  50. - The size of the buffers used in "tty" objects, "bsize"+1.
  51. - If a frame that is in the screen and above another, its area "areaw".
  52. No extra memory is allocated for the items of menus and settings.
  53. ********************************************************************************
  54. */
  55.  
  56. /*
  57.  * The variables marked "*" are reserved, and shall not be changed.
  58.  * The variables marked "#" are the ones usually initialized at creation.
  59.  * The others can be freely changed.
  60.  */
  61.  
  62. #define LOC_MOVE 256
  63.   /* event: mouse moved */
  64. #define LOC_DRAG 257
  65.   /* event: mouse moved with pressed buttons */
  66. #define MS_LEFT 1001
  67.   /* event: left button pressed */
  68. #define MS_MIDDLE 1004
  69.   /* event: middle button pressed */
  70. #define MS_RIGHT 1002
  71.   /* event: right button pressed */
  72. #define m_itens 20
  73.   /* maximum number of items in menus and settings  (only 16 in settings) */
  74. #define m_chars 59
  75.   /* caracters in strings */
  76. #define mrgx 5
  77.   /* lateral and bottom margins in the windows */
  78. #define mrgy 22
  79.   /* upper margin in the windows */
  80.  
  81.   typedef struct widget *Xv_opaque; /* C++ */
  82.   typedef enum { text_field,real_field,int_field } t_field_type;
  83.   typedef struct figstruct {              /* structue for images */
  84.     int blocks;                           /* number of image blocks -1 */
  85.     unsigned int blocksize,lastblocksize; /* size of the blocks */
  86.     void *v[2001];                        /* allocated until "blocks" */
  87.   } figstruct;
  88.   typedef struct figstruct *ptrfig;       /* imagem pointer */
  89.   typedef void (*xv_handler)(Xv_opaque obj);
  90.   typedef enum { frame,button,textfield,setting,message,canvas,tty,menu } xv_package;
  91.   typedef char xv_label_type[m_chars+1];
  92.   typedef struct widget {
  93.    xv_label_type xv_label;              /* # title */
  94.    int           x,y,dx,dy;             /* # position and size */
  95.    int           fore_color,back_color; /* # colors */
  96.    Xv_opaque     owner;                 /* * frame where the object is */
  97.    Xv_opaque     next;                  /* * next objeto */
  98.    Xv_opaque     menu_name;             /* # associated menu */
  99.    xv_handler    notify_handler;        /* # notify handler */
  100.    xv_handler    event_handler;         /* # event handler */
  101.    void          *client_data;          /* # other associated values */
  102.    xv_package o_type;                   /* * object type */
  103.     union {
  104.      struct { Xv_opaque over;
  105.               Xv_opaque under;        /* * neighbor window frames */
  106.               ptrfig    Pw;           /* * covered image */
  107.               long int areaw;         /* * size of image */
  108.            int       dxmin, dymin; /* # minimum size */
  109.            int       interfere;    /* * used internally */
  110.            int       mapped;       /* * if the window is in the screen */
  111.           int       adjust_exit;  /* # if the window can ba closed with the central mouse button */
  112.           Xv_opaque mouse_obj;    /* # initial location of the mouse (object), or nil */
  113.           struct viewporttype gr_out; } sframe;  /* * viewport */
  114.      struct { int       icon_label;   /* # if "xv_label" is a bitmap file name */
  115.               ptrfig    Pimageb; } sbutton;  /* * button image */
  116.      struct { int       icon_msg;     /* # if "xv_label" is a bitmap filename */
  117.               ptrfig    Pimagem; } smessage; /* *  message image */
  118.      struct { xv_label_type panel_value;    /* # text */
  119.           double panel_real;            /* # corresponding real */
  120.           int   panel_int;              /* # corresponding integer */
  121.           int   min_value, max_value;   /* # integer limits */
  122.           int   value_length;           /* # characters shown */
  123.           t_field_type field_type; } stextfield; /* type */
  124.      struct { int itens_setting;            /* * number of items */
  125.           int      sel_setting;         /* # selection */
  126.           char     *item_setting[m_itens]; /* * item strings */
  127.           int exclusive; } ssetting;       /* # if selection is exclusive */
  128.      struct { int can_xext,can_yext; } scanvas;  /* # if extends to the borders */
  129.      struct { int tty_xext,tty_yext;             /* # " */
  130.           int xc,yc;                   /* * graphical cursors */
  131.           unsigned int bsize;          /* * buffer size */
  132.           unsigned bcsr;               /* * buffer cursor */
  133.           unsigned bstart,tstart,tend; /* * buffer pointers */
  134.           int dxtty;                   /* * effective width */
  135.           char *Pb; } stty;            /* * text buffer */
  136.      struct { int itens_menu;           /* * number of de items */
  137.           int sel_menu;             /* # selected item */
  138.           char *item_menu[m_itens]; /* * item strings */
  139.           Xv_opaque item_submenu[m_itens]; } smenu;  /* # submenus */
  140.    } v;
  141.   } widget;
  142.  
  143.   extern int wallpaper;   /* 0 # if the background is to be retained */
  144.   extern unsigned int normal_bsize;  /* # "bsize" (tty) attributed by "xv_create" */
  145.   extern unsigned int normal_length; /* # "value_length" (textfield) attributed by "xv_create" */
  146.   extern int c_normal;    /* LIGHTGRAY     object background color */
  147.   extern int c_active;    /* GREEN         pressed buttons color */
  148.   extern int c_light;     /* WHITE         lighted corners color */
  149.   extern int c_shadow;    /* BLACK         shadowed corners color */
  150.   extern int c_white;     /* WHITE         default "back_color" */
  151.   extern int c_black;     /* BLACK         default "fore_color" */
  152.   extern int c_overwrite; /* LIGHTRED      overwrite color in textfields */
  153.   extern int c_edit;      /* BLUE          edit color in textfields */
  154.   extern int c_insert;    /* YELLOW        insert color in textfields */
  155.   extern int c_hatch;     /* CYAN          background pattern color */
  156.   extern int type_hatch;        /* XHATCH_FILL  background color */
  157.   extern int use_palette;       /* 1 if bitmap palettes are accepted */
  158.   extern void *normal_client_data; /* NULL attributed to "client_data" by "xv_create" */
  159.   extern int          nlines;   /* * 60, number of lines per image block */
  160.   extern int          insert;   /* 1 if textfields are insert mode */
  161.   extern int          xv_ok;    /* * resultd of the last window operation */
  162.   extern int          xv_end;   /* terminates "xv_main_loop" */
  163.   extern xv_label_type   ulttxt;    /* last text read in textfields */
  164.   extern int          ie_locx,ie_locy;   /* * mouse position relative to object */
  165.   extern int          ie_code;      /* * event code */
  166.   extern int          ie_shiftcode; /* * mouse buttons state */
  167.   extern Xv_opaque    active_w;     /* * the active window frame */
  168.   extern Xv_opaque    active_o;     /* * the active object */
  169.   extern Xv_opaque    w_base;       /* base frame for "xv_create" */
  170.   extern Xv_opaque    o_base;       /* base object for "item_create" */
  171.   extern int redrawing_frame;       /* if a window is being redrawn */
  172.   extern void (*interposer)(void);  /* routine called after each event */
  173.  
  174. extern void xv_init(int placa,int modo);
  175. /* General inicialization */
  176.  
  177. extern Xv_opaque xv_create(xv_package obj_type);
  178. /* Allocates and initializes with default values an object
  179.    Returns its pointer
  180.    Allocates the "tbuffer" of the "tty"s with Pb=malloc(bsize+1)
  181. */
  182.  
  183. extern void item_create(const char *txt);
  184. /* Creates an item for a menu or setting
  185.    The items are enumerated from 0 (1 in Pascal)
  186.    No memory is allocated
  187. */
  188.  
  189. extern void xv_main_loop(Xv_opaque w);
  190. /* Opens a window and initates the loop wait event - process event */
  191.  
  192. extern void open_window(Xv_opaque w);
  193. /* Opens or activates a window */
  194.  
  195. extern void close_window(Xv_opaque w);
  196. /* Closes a window, erasing it from the screen */
  197.  
  198. extern void ttysw_output(Xv_opaque terminal, const char *texto);
  199. /* Writes text to a terminal (tty) */
  200.  
  201. extern void Back(void);
  202. /* Puts the active window behind the others */
  203.  
  204. extern void xv_set(Xv_opaque obj, char *new_label);
  205. /* Changes the label of an object, redrawing it. Opens the object window */
  206.  
  207. extern void menu_show(Xv_opaque obj);
  208. /* Opens a menu at the mouse position */
  209.  
  210. extern void draw_object(Xv_opaque obj, int complete);
  211. /* Redraws an object */
  212.  
  213. extern void nothing(Xv_opaque obj);
  214. /* Default "notify_handler" and "event-handler". No action */
  215.  
  216. extern void nointerpose(void);
  217. /* Default "interposer". No action. */
  218.  
  219. extern void wait_button(void);
  220. /* Waits until the mouse buttons are released */
  221.  
  222. extern void drawbitmap(int x,int y,int* dw, int* dh, ptrfig *Pimg, const char *filename);
  223. /* Draws a Window 16 colors bitmap */
  224. /* The filename shall use "/", not "\" as directory separator (C bug?) */
  225.  
  226. /* The routines below are for operations with large images */
  227.  
  228. extern long int figuresize(int x1,int y1,int x2,int y2);
  229. /* Memory needed for an image */
  230.  
  231. extern void getfiguremem(ptrfig *p,int dw,int dh);
  232. /* Allocates memory for image. "dw" e "dh" are width-1 and height-1 */
  233.  
  234. extern void freefiguremem(ptrfig p);
  235. /* Frees memory allocated for an image */
  236.  
  237. extern void getfigure(int x1,int y1,int x2,int y2,ptrfig p);
  238. /* Captures an image from the screen */
  239.  
  240. extern void putfigure(int x,int y,ptrfig p,unsigned int bitblt);
  241. /* Draws a figure in the screen */
  242.  
  243. #endif
  244.  
  245.